package com.training.web.repository;

import com.training.bean.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface WebUserRepository extends JpaRepository<User, Integer> {

    // 自定义查询方法（按用户名查找）
    @Query("SELECT data FROM User data WHERE data.phone = :phone")
    User findUserByPhone(@Param("phone") String phone);

    // 自定义查询方法（按用户名查找）
    @Query("SELECT data FROM User data WHERE data.id = :id")
    User findUserById(@Param("id") int id);

    @Query("SELECT data FROM User data WHERE data.phone LIKE %:phone%")
    List<User> findUsersByPhone(@Param("phone") String phone);
}
